var post =  function(url,data)
{
  if (!data) data = {};
  return new Promise((resolve,reject)=>{
    data['session_key'] = wx.getStorageSync('session_key');
    if (!data['session_key'])reject('no_sessionkey');
    if (!url) reject('no_url');
    wx.request({
      url: url,
      data :data,
      method: 'POST',
      header: { 'content-type': 'application/x-www-form-urlencoded' },
      success: function (res) {
        if (res.data.code == 2000) {
          resolve(res.data.data);
        } else {//返回错误提示信息
          reject(res.data.msg);
        }
      },
      error: function (e) {
        reject('网络出错');
      }
    })
  })
}

module.exports = post;